package com.example.wechattest;

import android.content.Context;
import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.example.wechattest.myAdapter.WechatAdapter;

public class wechatFragment extends Fragment {

    private View rootView;
    private Context context;

    public wechatFragment(Context context) {
    this.context = context;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.wechat_fragment, container, false);
        init(rootView);

        return rootView;
    }

    private void init(View rootView) {
        RecyclerView recyclerView = rootView.findViewById(R.id.wechat_rl);
        //设置布局
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context,LinearLayoutManager.VERTICAL,false);
        recyclerView.setLayoutManager(linearLayoutManager);
        //设置适配器
        WechatAdapter wechatAdapter = new WechatAdapter(context);
        recyclerView.setAdapter(wechatAdapter);
    }
}